package com.lhb.SC.admin.feign;

import com.lhb.SC.admin.feign.codec.MonitorEncoder;
import com.lhb.SC.web.context.ResponseResult;
import feign.form.spring.SpringFormEncoder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(name = "lhb-SC-oss", path = "/oss/upload", configuration = {OssFeign.OssFeignConfiguration.class})
public interface OssFeign {

    @RequestMapping(value = "/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResponseResult<Object> handleFileUpload(@RequestPart("file") MultipartFile[] files);

    public static class OssFeignConfiguration {

        @Bean
        public MonitorEncoder monitorEncoder() {
            return new MonitorEncoder(new SpringFormEncoder());
        }
    }

}
